# $Id: PKGBUILD 81575 2012-12-24 15:00:09Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Judd Vinet <jvinet@zeroflux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>

# jason modified:
#  remove dependent on gtk
#  patch for issue 39 :https://code.google.com/p/distcc/issues/detail?id=39

pkgname=distcc
pkgver=3.1
pkgrel=10
pkgdesc="A distributed C, C++, Obj C compiler"
arch=('i686' 'x86_64' sh4)
url="http://code.google.com/p/distcc/"
license=('GPL')
depends=('gcc' 'popt' 'avahi')
makedepends=('pkgconfig' 'python2' 'dbus')
optdepends=('python2')
backup=('etc/conf.d/distccd'
	'etc/distcc/hosts')
source=(http://distcc.googlecode.com/files/${pkgname}-${pkgver}.tar.bz2
	distccd
	distccd.conf.d
	distccd.service
	001-patch.sh4twbox)
md5sums=('a1a9d3853df7133669fffec2a9aab9f3'
         '1c918474372c09304772c20c4de484fa'
         '239aae53250e3e35288cba566bc0bbf1'
         '09f0688da9c1840e518d2593bd5c3830'
         '4ec6cf62c5b4d79c04bbce6d4034b1b6')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  
  (cd src && patch -p0 < ${srcdir}/001-patch.sh4twbox )
  
#  [ -f Makefile ] || 
#  CFLAGS="-m4 -pipe -O3 -ffast-math" 
  PYTHON=/usr/bin/python2 ./configure --prefix=/usr \
	--with-gtk=no \
	--with-gui=no \
	--sysconfdir=/etc \
	--mandir=/usr/share/man \
	--without-avahi \

  make WERROR_CFLAGS= INCLUDESERVER_PYTHON=/usr/bin/python2
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make TEST_PYTHON=/usr/bin/python2 check
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}/" INCLUDESERVER_PYTHON=/usr/bin/python2 install
  install -D -m644 ${srcdir}/distccd.conf.d ${pkgdir}/etc/conf.d/distccd
  install -D -m755 ${srcdir}/distccd ${pkgdir}/etc/rc.d/distccd

  install -d ${pkgdir}/usr/lib/${pkgname}/bin
  ln -sf /usr/bin/${pkgname} ${pkgdir}/usr/lib/${pkgname}/bin/cc
  ln -sf /usr/bin/${pkgname} ${pkgdir}/usr/lib/${pkgname}/bin/gcc
  ln -sf /usr/bin/${pkgname} ${pkgdir}/usr/lib/${pkgname}/bin/g++
  ln -sf /usr/bin/${pkgname} ${pkgdir}/usr/lib/${pkgname}/bin/c++
  ln -sf /usr/bin/${pkgname} ${pkgdir}/usr/lib/${pkgname}/bin/cpp

  install -Dm0644 $srcdir/distccd.service $pkgdir/usr/lib/systemd/system/distccd.service
}
